<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增商户虚户政策')" />
    <th:block th:include="include :: datetimepicker-css" />
        <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-virtualPolicy-add"  enctype="multipart/form-data">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">账户类型：</label>
                <div class="col-sm-8">
                    <select name="types" class="form-control m-b" required>
                        <option value="2">平台</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">满额提现金额(元)：</label>
                <div class="col-sm-8">
                    <input name="maxTx" required class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">自动提现周期(天)：</label>
                <div class="col-sm-8">
                    <input name="cycleTx" required class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">提现生效日期：</label>
                <div class="col-sm-8">
                    <input id="cycleDate" required readonly name="cycleDate" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">商户文件：</label>
                <div class="col-sm-8">
                    <span class="btn btn-white btn-file">
                        <input type="file" required name="file"  accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" />
                    </span>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "accounts/virtualPolicy"
        $("#form-virtualPolicy-add").validate({
            focusCleanup: true
        });

        $("input[name='cycleDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = new FormData($("#form-virtualPolicy-add")[0]);
                $.ajax({
                    url: prefix + "/add",
                    data: data,
                    type: "post",
                    cache: false,
                    dataType: "json",
                    cache: false,//上传文件无需缓存
                    processData: false,//用于对data参数进行序列化处理 这里必须false
                    contentType: false, //必须
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍后...");
                    },
                    success: function (result) {
                        if (result.code == '0') {
                            $.operate.successCallback(result);
                        }else {
                            $.modal.alertError(result.msg);
                        }
                        $.modal.closeLoading();
                    },
                })
            }
        }
    </script>
</body>
</html>